<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								名称：<input type="text" name="caseName"/>
							</li>


							<li>
								脚本名称：<input type="text" name="scriptName"/>
							</li>


							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('jmeter:jmeterTestCase:edit')}]];
        var removeFlag = [[${@permission.hasPermi('jmeter:jmeterTestCase:remove')}]];
        var prefix = ctx + "jmeter/jmeterTestCase";
		var jarPrefix = ctx + "jmeter/jmeterJarMgt";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
				copyUrl:  prefix + "/copy/{id}",
                modalName: "jmeter测试用例",
				search: false,
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'id', 
					title : '',
					visible: false
				},
				{
					field : 'caseName', 
					title : '名称',
					sortable: true
				},
				{
					field : 'scriptName',
					title : '脚本名称',
					sortable: true
				},
				{
					field : 'threadsNum', 
					title : 'threads_num',
					sortable: true
				},
				{
					field : 'threadsDelay', 
					title : 'threads_delay',
					sortable: true
				},
				{
					field : 'startUserCount', 
					title : 'start_user_count',
					sortable: true
				},
				{
					field : 'startUserBurst', 
					title : 'start_user_burst',
					sortable: true
				},
				{
					field : 'startUserPeriod', 
					title : 'stop_user_period',
					sortable: true
				},
				{
					field : 'stopUserCount', 
					title : 'stop_user_count',
					sortable: true
				},
				{
					field : 'stopUserPeriod', 
					title : 'stop_user_period',
					sortable: true
				},
				{
					field : 'rampUp', 
					title : 'ramp_up',
					sortable: true
				},
				{
					field : 'scriptLocation',
					title : '脚本地址',
					sortable: true
				},
				{
					field : 'nodeIds', 
					title : '分配的客户端id 英文逗号拼接',
					sortable: true
				},
				{
					field : 'prevCaseId', 
					title : '前置测试用例id',
					sortable: true
				},
				{
					field : 'addBy', 
					title : '提交用户名称',
					sortable: true
				},
				{
					field : 'updateBy', 
					title : '修改用户名称',
					sortable: true
				}]
            };
            $.table.init(options);
        });



		/*添加选择的用例到测试计划中*/
		function submitHandler(jarId,index){
			var rows = $.map($('#bootstrap-table').bootstrapTable('getSelections'), function (row) {
				return row.id;
			});

			$.modal.confirm("确认保存您选择的用例吗?", function() {

				var config = {
					url: jarPrefix + "/saveJarCase",
					type: "post",
					dataType: "json",
					contentType:"application/json",
					data: JSON.stringify({jarId:jarId,caseIdList:rows}),
					beforeSend: function () {
					},
					success: function(result) {
						$.modal.msgSuccess(result.msg);
						$.modal.closeLoading();
						$.modal.enable();
						layer.close(index)
					}
				};
				$.ajax(config);
			});

		}


		$('#bootstrap-table').on('load-success.bs.table', function (e,data) {
			var ids=[[${relCaseIdList}]];
			$('#bootstrap-table').bootstrapTable('checkBy', {field: 'id', values: ids})
		});




    </script>
</body>
</html>